<!DOCTYPE html>
<html>

	<head>
		<title>我的消息</title>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
		<script src="/js/jquery/jquery.min.js"></script>
		<script src="/js/bootstrap/js/bootstrap.js"></script>
		<link rel="stylesheet" href="/css/font/css/font-awesome.min.css" />
		<link rel="stylesheet" href="/css/reset.css" />
		<link rel="stylesheet" href="/css/message.css" />
		<script src="../../js/plugins/jrender/jrender.min.js"></script>
		<script>
			$(function () {

                // 获得当前用户id
                var user = JSON.parse(sessionStorage.getItem("user"));
                var userId = user.id;
                // 查询有多少评论
                var comment = $.ajax({
                    "dataType": 'json',

                    "url": "/comment/getMessages",
                    "data": {"userId": userId},
                    "success": function (data) {
                        if(data == null){
                            $(".comments").detach();
						}
                        var html="";
                        $.each(data,function (index, value) {
                            var state = value.state;
                            console.log(state);
                            if(state === 1){
                                html += '<dd>' +
                                    '<span class="badge badge-danger badge-pill" >未读</span>' +
                                    '<span><img src=' + value.headImgUrl + ' width="20px"></span>' +
                                    '<span >'+value.username+'</span> <span>评论了你的游记 : <a >'+value.targetname+'</a></span>' +
									'</br> &gt;&gt;'+
									'<p >'+value.content+'</p>' +
                                    '<span>'+value.create_time+'</span>' +
                                    '</dd>'+
                                '<hr>';
                                return;
							}
							if(state == 0){
                                html += '<dd>' +
                                    '<span><img src=' + value.headImgUrl + ' width="20px"></span>' +
                                    '<span>'+value.username+'</span> <span>评论了你的游记 : <a >'+value.targetname+'</a></span>' +
                                    '</br> &gt;&gt;'+
									'<p>'+value.content+'</p>' +
                                    '<span>'+value.create_time+'</span>' +
                                    '</dd>'+
								'<hr>';
                                return;
							}
                        })

						$(".comments").append(html)
                    }
                });
				var state ;
                $(".choseState").click(function () {
                    state = 0;
					$.post("/comment/setMessageState",{state:state},function (data) {
						if(data.success){
						    window.location.href="/mine/message/message.html";
						}
                    })
                })

            })
		</script>


	</head>

	<body>

	<div class="search-head">
		<div class="row nav-search choseState">
			<div class="col">
				<span><i class="fa fa-chevron-left" ></i></span>
			</div>
			<div class="col">
				<span>评论消息</span>
			</div>
			<div class="col"></div>
		</div>
	</div>


	</div>
        <div class="container comments">
            <!--<dl class="itemList" render-loop="list">
                <dd>
					<span class="badge badge-danger badge-pill dot" set-fun=".dot" render-key="list.state" >未读</span>
                    <span><img render-src="list.headImgUrl" width="20px"></span>
                    <span render-html="list.username"></span> <span>评论了你的游记 : <a render-html="list.targetname"></a></span>
					<p render-html="list.content"></p>
                    <span render-html="list.create_time"></span>
                </dd>
            </dl>-->
        </div>

	</body>

</html>